//
//  RBMediaPlayerVC.m
//  ZCPlayer
//
//  Created by Mac on 2020/12/1.
//

#import "RBMediaPlayerVC.h"
#import "RBMediaPlayerView.h"

@interface RBMediaPlayerVC ()

@property(nonatomic, strong) RBMediaPlayerView *playerView;

@end

@implementation RBMediaPlayerVC

#pragma mark - Lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self setup];
}

#pragma mark - Private

- (void)setup
{
    self.view.backgroundColor = UIColor.blackColor;
    
    if (self.name)
    {
        self.title = self.name;
    }
    
    __weak typeof(self) weak_self = self;
    RBMediaPlayerView *view = RBMediaPlayerView.new;
    [view setURL:self.url timeOffset:self.seekTime title:self.name playImmediately:YES];
    [self.view addSubview:view];
    CGFloat safeBottomHeight = 0;
    if (@available(iOS 11.0, *)){
        safeBottomHeight = UIApplication.sharedApplication.keyWindow.safeAreaInsets.bottom;
    };
    CGFloat width = self.view.bounds.size.width;
    CGFloat height = self.view.bounds.size.height;
    height -= safeBottomHeight;
    view.frame = CGRectMake(0, 0, width, height);
    view.playTimeBlock = ^(CGFloat currentTime) {
        if (weak_self.playTimeBlock)
        {
            weak_self.playTimeBlock(currentTime, weak_self.url);
        }
    };
}

#pragma mark - Network

#pragma mark - Event

#pragma mark - Setter

#pragma mark - Getter

@end
